<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>v-for 变量对象</title>
</head>
<body>
<div id="app">
    <ul>
        <li>{{ person.name }}</li>
        <li>{{ person.age }}</li>
        <li>{{ person.gender }}</li>
    </ul>


    <hr>

    <ul>
        <li v-for="item in person">{{ item }}</li>
    </ul>

    <!--原生的写法只能硬写-->
    <ul>
        <li>{{ 'name'}}: {{ person.name }}</li>
        <li>{{'age'}}: {{ person.age }}</li>
        <li>{{ 'gender'}}: {{ person.gender }}</li>
    </ul>

    <hr>
    <ul>
        <!--格式：对象的 value 写在前，对象的 key 写在 后-->
        <li v-for="(item,key) in person">{{key}}: {{ item }}</li>
    </ul>

    <hr>
    <ul>
        <!--索引一定要写到 最后-->
        <li v-for="(item,key, index) in person">{{ index }}.{{key}}: {{ item }}</li>
    </ul>
</div>

<script type="module">
    import {createApp, reactive} from "../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {
                let person = reactive({
                    name: "abcque",
                    age: 18,
                    gender: "M"
                })
                return {
                    person
                }
            }
        }
    );

    app.mount("#app")
</script>
</body>
</html>